
import config from './config'
export default (url, data={}, method='GET') => {
    return new Promise((resolve, reject) => {
        wx.request({
            url: config.host + url,
            data,
            method,
            header: {
                // cookies: wx.getStorageSync('cookies')?wx.getStorageSync('cookies').find(item => item.indexOf('MUSIC_U') !== -1):''
                // cookies: wx.getStorageSync('cookies')[3]
                // cookie: 'MUSIC_U=b85c4f94712392f3b1d9914cd14db50a53b0b4cedfa830428eee3d524eae4836519e07624a9f0053d78b6050a17a35e705925a4e6992f61d07c385928f88e8de; Max-Age=1296000; Expires=Thu 23 Dec 2021 11:46:01 GMT; Path=/;'
                cookie:'MUSIC_R_T=1638875134211; MUSIC_A_T=1638875134056; _ntes_nuid=aeb06dc7b75c2f95f187c05cc39f72da; NMTID=00OQcwcCJ-Gbc_5NUuigLeTJWYh5oUAAAF9IzH40Q; WEVNSM=1.0.0; WNMCID=txikun.1636973017912.01.0; WM_TID=%2FuvIGvcNfZ9BFFBVUAZ6ox0fGgO6mTPR; ntes_kaola_ad=1; __snaker__id=V54waRiBMTfIA10o; _9755xjdesxxd_=32; _ntes_nnid=aeb06dc7b75c2f95f187c05cc39f72da,1677202219557; JSESSIONID-WYYY=cCpEuwoC%2FIYy2tqm5eCgsC1UyhAbDQSK2napls8%5ChOnpCd8tiyWJVNtinye%2FpXG61bxVS%2BxCvClElD5tJystxRWs1jNXjJnDbQ48EKqsoPaxyijd62EYak9pujapY%5CDaHFPtyIyEej55HnP5Ek8%5Cyms%5CYbN%2F7ZqMZvG%5C9zV0Tdoa6TWj%3A1677204020538; _iuqxldmzr_=33; WM_NI=eCZdWbD8rN0cA8qwT9fX%2BPbo%2FUSihc2Un2LmwLCRMAXtGUj22gzuckt8NkzdxCurDFlTjKleKysosMnErNW5c8TmVY5vUJ87GPhxg3dODTe9TlM0xFo1kmYfcL8SU2b0bWI%3D; WM_NIKE=9ca17ae2e6ffcda170e2e6eea6e15bedb3e1b7ed43f5bc8ea3d44e938b9e82d841a19e9db7d072ad87a891b72af0fea7c3b92aa79d9685d66a88e8beafb36983e8bf98d733a688e5b1e165ed8b9d8aeb69f28ba2d3cf67b5948db3d04b9cac89b6e93af2b9b696e261b8e8828cf970bc9dbb93c74eb08ca6acef6f89a7bd90f247ae9bbeafd63fa1e89c8ed553f7aa9babbb3d8590a899e639a8918cb5e83398b483d1fb4eadefa58edc6ea194f8b4d83aa2f0aeb8cc37e2a3; gdxidpyhxdE=MzOxPynjciutQhPKuXjYDwnzUtBMY0gMyPSjRDo1QU4BeMCziKd9%5CM0UNMba5MrZ0n6C63ubQLQc%2BYkz7VPWCAAKNZ3lVCYx9Isn5u%5CrAIPPlPSGNObRvgVy6w51Sv0L4og1a32IQLeNTot2yottSrQhspRaA8H1m51lyJG6B8kg8ssg%3A1677203121530; YD00000558929251%3AWM_NI=ZMWC50LAYLIK99Vyv%2BP6gQJKS51nYJnVwGLJtKyMe6j84gIWNOdSz%2BwwA2z1FYqXm7KGfS8XtRehjmmfPvON15p1Yn1hcvReZ9cnkVw67l4kVizuAVDKgc9ZLgui%2BXOYTkI%3D; YD00000558929251%3AWM_NIKE=9ca17ae2e6ffcda170e2e6ee93eb41968997a6b353fcb88ea2d55a838e8b83d5418b9b88b6e766b4b9aaadd32af0fea7c3b92a9a9399a4b83c909f97adcc41fbe79a9af52194eaa9b2c94191ebff8fdc42ae8ab9a8cf42b895b7aee83eaae8fc88cc5d8e91acb4f921b5a98fd3f93b8687bfb9f03d8999aab4bb54b88eab89e967afbaa097ce46f3ebc0d2dc66f3b8ad97d16f9ae7ad8fea5eb5eaf98db76196b7b696c45e8895a984bc5290b9bb8aaa548d879c8ccc37e2a3; YD00000558929251%3AWM_TID=HdzfkYUBM8NFEERUAUPUPMRWAImthKPP; MUSIC_U=b85c4f94712392f3b1d9914cd14db50a2a18d8784ba2dff5be9def0e2e834e151e8907c67206e1ed413c73a40e2630f8904ff4c0ebc68ac2855555a360109477610b4bf3332f63d1d4dbf082a8813684; __csrf=7334a1ea57f9b34259160bd4523f20a5'
            },
            success:(res) =>{
                if(data.islogin){
                    wx.setStorage({
                        key: 'cookies',
                        data: res.cookies
                    })
                }
                resolve(res.data);
            },
            fail:(err) =>{
                // console.log('请求失败：', err);
                rejects(err);
            }
          })
    })
}